package cn.edu.neusoft.config;

import com.dahuatech.icc.oauth.model.v202010.OauthConfigUserPwdInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class OauthConfigUtil {
    @Autowired
    private PlatformConfig platformConfig;
    /**
     * 获取Oauth配置信息
     *
     * @return Oauth配置信息
     */
    public OauthConfigUserPwdInfo getOauthConfig() {
        OauthConfigUserPwdInfo oauthConfigUserPwdInfo = new OauthConfigUserPwdInfo(
                platformConfig.getHost(),
                platformConfig.getClientId(),
                platformConfig.getClientSecret(),
                platformConfig.getUsername(),
                platformConfig.getPassword(),
                false,
                platformConfig.getHttpsPort(),
                platformConfig.getHttpPort()
        );
        oauthConfigUserPwdInfo.getHttpConfigInfo().setReadTimeout(platformConfig.getReadTimeout());
        oauthConfigUserPwdInfo.getHttpConfigInfo().setConnectionTimeout(platformConfig.getConnectionTimeout());
        return oauthConfigUserPwdInfo;
    }
}
